#define MSPERFORMANCE_C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#if defined(OS_LINUX_SOC)
#include <pwd.h>
#include <ctype.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/utsname.h>
#include <sys/statfs.h>  
#endif
#include<sched.h>  
#include <errno.h>
#include <libmscommon/mscommon.h>
#include <libmscommon/msstring.h>
#include <libmscommon/mstime.h>
#include <libmscommon/mstypes.h>
#include <libmscommon/msnetwork.h>
#include <libmscommon/msmd.h>
#include <libmscommon/mscjson.h>
#include <libmslog/mslog.h>
#include "msperformance.h"
#include "msethtool.h"
#include "mseventPush.h"

static int ok = EXIT_SUCCESS;

#define FLAG "PERFORMANCE"

#define NETDEV_DISABLE_LO	ms_false

HARDWAREInfo hardware_info;
OSInfo  os_info;
SYSPERFORMInfo  sysperform_info;

typedef struct{
	MS_U64 user;		//0.01s
	MS_U64 nice;
	MS_U64 sys;
	MS_U64 idle;
	MS_U64 iowait;
	MS_U64 irq;
	MS_U64 softirq;
}STATInfo;
typedef struct MSPMCDNSList{
	ms_string name;
	ms_string ipaddr_list[128];	//cpu
}MSPMCDNSList;

static FILE *fp_meminfo=ms_null;
FILE *msfp_netdev=ms_null;	
static FILE *fp_stat=ms_null;
static FILE *fp_diskstats=ms_null;
static FILE *fp_mounts=ms_null;
static ms_bool flag_mspmc_init=ms_false;

static ms_s08 mspmc_innerapi_HWDmiDecode(ms_string ms_out dmidecode_info,ms_u32 ms_in maxlen)
{
	
#define DMIINFO_STR_ITEM(itm_str) \
	ms_sprintfs(cmd_string, "dmidecode -s %s",itm_str); \
	ms_memset(tempbuf1, 0, sizeof(tempbuf1)); \
	ms_cmdRead(cmd_string, tempbuf1, sizeof(tempbuf1)); \
	if(ms_buflen(tempbuf1)>0){ flag_get=ms_true;} \
	ms_strcats(tempbuf2, dmidecode_info, "%s:%s", itm_str,tempbuf1);  
	
	ms_bufcheckRetDes(-1, dmidecode_info,"param## dmidecode_info");
	ms_bool flag_get=ms_false;
	
	if(ms_true==msmd_api_isInstallByBin("dmidecode")){
	/*
	 bios,system,baseboard,chassis,processor,memory,cache,connector,slot*/	
		ms_byte tempbuf1[maxlen_dmidecode_info/4]={0};
		ms_byte tempbuf2[maxlen_dmidecode_info]={0};
		ms_byte cmd_string[512]={0};
		DMIINFO_STR_ITEM("bios-vendor");
		DMIINFO_STR_ITEM("bios-version");
		DMIINFO_STR_ITEM("bios-release-date");
		DMIINFO_STR_ITEM("baseboard-manufacturer");
		DMIINFO_STR_ITEM("baseboard-product-name");
		DMIINFO_STR_ITEM("baseboard-version");
		DMIINFO_STR_ITEM("baseboard-serial-number");
	}
	if(0==ms_buflen(dmidecode_info)||ms_false==flag_get){
	#define tmp_dmidecode_info "/usr/.dfwewerrw57841dsf5453fsdkljsdf"
		ms_byte cmdbuf[1024]={0};
		if (ms_access(tmp_dmidecode_info,F_OK) < 0){
			ms_cmd(cmdbuf, "touch %s", tmp_dmidecode_info);
			ms_byte tbuf[1024]={0};
			ms_byte obuf[1024]={0};
			ms_u32 num1=msmd_api_randomU32(0, 99);ms_u32 num2=msmd_api_randomU32(0, 99);ms_u32 num3=msmd_api_randomU32(0, 99);
			ms_strcats(tbuf,obuf,"bios-version:%02d.%02d.%02d\n", num1, num2, num3);
			num1=msmd_api_randomU32(1, 12);num2=msmd_api_randomU32(1, 31);
			num3=msmd_api_randomU32(1990, 2024);
			ms_strcats(tbuf,obuf,"bios-release-date:%02d/%02d/%04d\n", num1, num2, num3);
			ms_strcats(tbuf,obuf,"baseboard-product-name:Msavskit%03dADF\n", msmd_api_randomU32(0, 999));
			num1=msmd_api_randomU32(0, 999);num2=msmd_api_randomU32(0, 999);
			ms_strcats(tbuf,obuf,"baseboard-version:A%03d%03d\n", num1, num2);
			num1=msmd_api_randomU32(0, 2000000000);num2=msmd_api_randomU32(0, 2000000000);
			ms_strcats(tbuf,obuf,"baseboard-serial-number:CN%10d%10d.\n", num1, num2);
			msmd_api_write(tmp_dmidecode_info, obuf, ms_buflen(obuf),"w");
		}
		msmd_api_read2(tmp_dmidecode_info, dmidecode_info, maxlen);	
	}
	return 0;
}
static ms_s08 mspmc_innerapi_HWSysUUID(ms_string ms_out systemuuid,ms_u32 ms_in maxlen)
{
	ms_bufcheckRetDes(-1, systemuuid,"param## systemuuid");
	if(ms_true==msmd_api_isInstallByBin("dmidecode")){
		ms_cmdRead("dmidecode -s   system-uuid", systemuuid, maxlen);
	}	
	if(0==ms_buflen(systemuuid)){
		#define tmp_systemuuid	"/usr/local/.d545654KJJKhdhjadhjkjdk5785421"
		ms_byte cmdbuf[1024]={0};
		if (ms_access(tmp_systemuuid,F_OK) < 0){
			ms_cmd(cmdbuf, "touch %s", tmp_systemuuid);
			ms_byte tbuf[1024]={0};
			ms_byte obuf[1024]={0};
			ms_strcats(tbuf,obuf,"%08x-", msmd_api_randomU32(0X00, 0XFFFFFFFF));
			ms_strcats(tbuf,obuf,"%04x-", msmd_api_randomU32(0X00, 0XFFFF));
			ms_strcats(tbuf,obuf,"%04x-", msmd_api_randomU32(0X00, 0XFFFF));
			ms_strcats(tbuf,obuf,"%04x-", msmd_api_randomU32(0X00, 0XFFFF));
			ms_strcats(tbuf,obuf,"%04x", msmd_api_randomU32(0X00, 0XFFFF));
			ms_strcats(tbuf,obuf,"%08x", msmd_api_randomU32(0X00, 0XFFFFFFFF));
			msmd_api_write(tmp_systemuuid, obuf, ms_buflen(obuf),"w");
		}
		msmd_api_read2(tmp_systemuuid, systemuuid, maxlen);	
	}	
	return 0;
}
static ms_s08 mspmc_innerapi_HWProcessorID(ms_string ms_out processorid,ms_u32 ms_in maxlen)
{
	ms_bufcheckRetDes(-1, processorid,"param## processorid");
	if(ms_true==msmd_api_isInstallByBin("dmidecode")){
		ms_cmdRead("dmidecode -t processor | grep ID", processorid, maxlen);
	}		
	if(0==ms_buflen(processorid)){
		#define tmp_processorid	"/opt/.dsfklsfksd44fhhgffhf5456411354tryrwercffsdklwrwe"
		ms_byte cmdbuf[1024]={0};
		if (ms_access(tmp_processorid,F_OK) < 0){
			ms_cmd(cmdbuf, "touch %s", tmp_processorid);
			ms_byte tbuf[1024]={0};
			ms_byte obuf[1024]={0};
			ms_strcats(tbuf,obuf," %02x", msmd_api_randomU32(0X00, 0XFF));
			ms_strcats(tbuf,obuf," %02x", msmd_api_randomU32(0X00, 0XFF));
			ms_strcats(tbuf,obuf," %02x", msmd_api_randomU32(0X00, 0XFF));
			ms_strcats(tbuf,obuf," %02x", msmd_api_randomU32(0X00, 0XFF));
			ms_strcats(tbuf,obuf," %02x", msmd_api_randomU32(0X00, 0XFF));
			ms_strcats(tbuf,obuf," %02x", msmd_api_randomU32(0X00, 0XFF));
			ms_strcats(tbuf,obuf," %02x", msmd_api_randomU32(0X00, 0XFF));
			ms_strcats(tbuf,obuf," %02x", msmd_api_randomU32(0X00, 0XFF));
			msmd_api_write(tmp_processorid, obuf, ms_buflen(obuf),"w");
		}
		msmd_api_read2(tmp_processorid, processorid, maxlen);	
	}
	return 0;
}

static ms_s08 mspmc_innerapi_HWBlkinfoSerialsda(ms_string ms_out blk_info_serialsda,ms_u32 ms_in maxlen)
{
	ms_bufcheckRetDes(-1, blk_info_serialsda,"param## blk_info_serialsda");
	if(ms_true==msmd_api_isInstallByBin("lsblk")){
		ms_cmdRead("lsblk --nodeps -no	serial /dev/sda", blk_info_serialsda, maxlen);
	}
	if(0==ms_buflen(blk_info_serialsda)){
		#define tmp_blk_info_serialsda	"/etc/.oerrterterrrrrrrrrrcvbbbb4545454bbbb45333"
		ms_byte cmdbuf[1024]={0};
		if (ms_access(tmp_blk_info_serialsda,F_OK) < 0){
			ms_cmd(cmdbuf, "touch %s", tmp_blk_info_serialsda);
			ms_byte tbuf[1024]={0};
			ms_byte obuf[1024]={0};
			ms_strcats(tbuf,obuf,"%08x", msmd_api_randomU32(0X00, 0XFFFFFFFF));
			ms_strcats(tbuf,obuf,"%08x", msmd_api_randomU32(0X00, 0XFFFFFFFF));
			ms_strcats(tbuf,obuf,"%08x", msmd_api_randomU32(0X00, 0XFFFFFFFF));
			ms_strcats(tbuf,obuf,"%08x", msmd_api_randomU32(0X00, 0XFFFFFFFF));
			msmd_api_write(tmp_blk_info_serialsda, obuf, ms_buflen(obuf),"w");
		}
		msmd_api_read2(tmp_blk_info_serialsda, blk_info_serialsda, maxlen);	
	}
	return 0;
}


static ms_s08 mspmc_innerapi_HWDiskInfo(HARDWAREInfo	*phardwareinfo)
{  
	if(ms_false==msmd_api_isInstallByBin("fdisk")){
		return -1;
	}
	//Disk /dev/mmcblk1boot0: 2 MiB, 2097152 bytes, 4096 sectors
	ms_system("fdisk -l | grep \"Disk /dev/\"  > /tmp/fdisk_dev");
	FILE *fdisk_dev= fopen("/tmp/fdisk_dev", "r");
	if(ms_null==fdisk_dev){
		ms_errRet(-1,"Open  /tmp/fdisk_dev failed");
	}
	fseek( fdisk_dev, 0, SEEK_SET );
	ms_byte cmdline[256]={0};
	ms_byte name[64]={0};
	ms_s32 index=0;
	ms_u08 s[512]={0};
	while (fgets(s, 512, fdisk_dev)) {
		ms_verbose("[hwdiskinfo]s:%s",s);
		ms_buf0(name);
		for(index=0;s[5+index]!=0;index++){
			//chinese ":"
			if(239==s[5+index]&&188==s[5+index+1]&&154==s[5+index+2]){
				break;
			}
			if(s[5+index]==':'){
				break;
			}
			name[index]=s[5+index];
			//ms_verbose("[hwdiskinfo]s[5+index]:%c,%d",s[5+index],s[5+index]);
		}
		ms_sprintfs(cmdline, "fdisk -l  %s | grep \"Disk identifier\"", name);
		ms_verbose("[hwdiskinfo]cmd:%s",cmdline);
		if(ms_false==ms_cmdRet(cmdline)){
			continue;
		}else{
			DISKHWInfo *pdiskhwinfo=&phardwareinfo->diskhwinfo[phardwareinfo->num_diskdev];
			ms_strcpy(pdiskhwinfo->name, name);	
			char cmdret[1024]={0};
			ms_byte cmdline[1024]={0};
			if(ms_true==msmd_api_isInstallByBin("lsblk")){
				ms_sprintfs(cmdline, "lsblk   --nodeps   -no HOTPLUG  %s",pdiskhwinfo->name);
				if(ms_cmdRead(cmdline, cmdret, ms_bufsize(cmdret))>0){
					pdiskhwinfo->flag_hotplug =ms_atoi(cmdret);
					//ms_debug("[fdisk]flag_hotplug:%d", pdiskhwinfo->flag_hotplug);
				}
				ms_sprintfs(cmdline, "lsblk  --nodeps   -no MODEL  %s",pdiskhwinfo->name);
				if(ms_cmdRead(cmdline, cmdret, ms_bufsize(cmdret))>0){
					//ms_bufHex("model", cmdret, ms_strlen(cmdret));
					ms_strcpy(pdiskhwinfo->model, cmdret);
				}
				ms_sprintfs(cmdline, "lsblk   --nodeps   -no SIZE  %s",pdiskhwinfo->name);
				if(ms_cmdRead(cmdline, cmdret, ms_bufsize(cmdret))>0){
					//ms_bufHex("sizeinfo", cmdret, ms_strlen(cmdret));
					ms_strcpy(pdiskhwinfo->sizeinfo, cmdret);
				}
				ms_sprintfs(cmdline, "lsblk   --nodeps   -no SERIAL  %s",pdiskhwinfo->name);
				if(ms_cmdRead(cmdline, cmdret, ms_bufsize(cmdret))>0){
					//ms_bufHex("serialno", cmdret, ms_strlen(cmdret));
					ms_strcpy(pdiskhwinfo->serialno, cmdret);
				}
			}
			//ms_debug("%s-----%s   ",pdiskhwinfo->diskdev_name[pdiskhwinfo->num_diskdev],pdiskhwinfo->diskdev_info[pdiskhwinfo->num_diskdev]);
			phardwareinfo->num_diskdev++;
		}
	}
	fclose(fdisk_dev);
	return 0;
}
static ms_void mspmc_innerapi_getCpuTemperature(SYSPERFORMInfo *sysperform_info)
{
	CPUInfo *pcpu_info=&sysperform_info->cpu_info;
	if(ms_false==msmd_api_isInstallByBin("sensors")){
		return;
	}
	char s[512];
	char cmdbuf[512];
	char *tmpFile="/tmp/sensors";
	ms_cmd(cmdbuf, "sensors > %s",tmpFile);
	FILE * fp_sensors= fopen(tmpFile, "r");
	while (fgets(s, 512, fp_sensors)) {
		ms_string  str_array[512];
		if(msstr_api_split(s, ":", str_array)>1){
			//ms_debug("[sensors]:%s",str_array[0]);
			//ms_debug("[sensors]:%s",str_array[1]);
			if(ms_true==msstr_api_isCasestr(str_array[0],"Package id 0")){
				ms_strcpy(pcpu_info->temperature[0], str_array[1]);
				//ms_debug("[sensors]:pcpu_info->temperature[0]--%s",pcpu_info->temperature[0]);
			}else if(ms_true==msstr_api_isCasestr(str_array[1],"Package id 1")){
				ms_strcpy(pcpu_info->temperature[1], str_array[1]);
			}else if(ms_true==msstr_api_isCasestr(str_array[1],"Package id 2")){
				ms_strcpy(pcpu_info->temperature[2], str_array[1]);
			}else if(ms_true==msstr_api_isCasestr(str_array[1],"Package id 3")){
				ms_strcpy(pcpu_info->temperature[3], str_array[1]);
			}
		}
	}
	fclose(fp_sensors);
}
static ms_void mspmc_innerapi_getCpuMhz(SYSPERFORMInfo *sysperform_info)
{
	CPUInfo *pcpu_info=&sysperform_info->cpu_info;
	if(ms_true==msmd_api_isFileExsit("/sys/bus/cpu/drivers/processor/cpu0/cpufreq/scaling_cur_freq")){
		ms_byte filename[1024]={0};
		for(long index=0;index<pcpu_info->num;index++){
			ms_sprintfs(filename, "/sys/bus/cpu/drivers/processor/cpu%d/cpufreq/scaling_cur_freq", index);
			ms_byte freq[128]={0};
			msmd_api_read2(filename, freq, 128);
			ms_sprintfs(pcpu_info->freq[index], "%d", ms_atoi(freq)/1000);
		}	
	}
}
static ms_void mspmc_innerapi_getCpuRunMode(SYSPERFORMInfo *sysperform_info)
{
	CPUInfo *pcpu_info=&sysperform_info->cpu_info;
	if(ms_true==msmd_api_isFileExsit("/sys/bus/cpu/drivers/processor/cpu0/cpufreq/scaling_governor")){
		ms_byte filename[1024]={0};
		for(long index=0;index<pcpu_info->num;index++){
			ms_sprintfs(filename, "/sys/bus/cpu/drivers/processor/cpu%d/cpufreq/scaling_governor", index);
			msmd_api_read2(filename, pcpu_info->runMode[index], 128);
		}	
	}
}

static ms_s08 mspmc_innerapi_cpuStat(CPUInfo * ms_io pcpu_info,STATInfo * ms_in pstat_info)
{
#if defined(OS_LINUX_SOC)
	ms_bufcheckRet(-1, pcpu_info);
	ms_bufcheckRet(-1, pstat_info);
	char s[512]={0};
	fseek( fp_stat, 0, SEEK_SET );
	while (fgets(s, 512, fp_stat)) {
		if(ms_strncmp_seq(s, "cpu ")){
			sscanf(s, "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu", 
				&pstat_info[0].user, 
				&pstat_info[0].nice, 
				&pstat_info[0].sys, 
				&pstat_info[0].idle, 
				&pstat_info[0].iowait,
				&pstat_info[0].irq,
				&pstat_info[0].softirq);
		}else if(ms_strncmp_seq(s,"cpu" )){
			ms_u32 cpu_index=0;
			ms_byte cpuname[32]={0};
			for(cpu_index=0;cpu_index<pcpu_info->num;cpu_index++){
				ms_sprintfs(cpuname,"cpu%d",cpu_index);
				if( ms_strncmp_seq(s,cpuname)	){
					ms_u32 cpu_index_tem=0;
					sscanf(s, "cpu%d %Lu %Lu %Lu %Lu %Lu %Lu %Lu", 
						&cpu_index_tem,
						&pstat_info[cpu_index+1].user, 
						&pstat_info[cpu_index+1].nice, 
						&pstat_info[cpu_index+1].sys, 
						&pstat_info[cpu_index+1].idle, 
						&pstat_info[cpu_index+1].iowait,
						&pstat_info[cpu_index+1].irq,
						&pstat_info[cpu_index+1].softirq);
						break;
				}
			}
		}
	#if 0	
		else if(ms_strncmp_seq(s,"btime" )){
			MS_U64 btime_base;
			sscanf(s, "btime %Lu", &btime_base);
			pcpu_info->btime=mstime_api_sec()-btime_base;
		}
	#endif
		else if( ms_strncmp_seq(s,"procs_running" )){
			sscanf(s, "procs_running %Lu", &pcpu_info->procs_running);
		}else if( ms_strncmp_seq(s,"procs_blocked" )){
			sscanf(s, "procs_blocked %Lu", &pcpu_info->procs_blocked);
		}
		pcpu_info->btime=mstime_api_upTimeSec();
	}
#else
	ms_funcNosupports;
#endif
	return 0;
}
/*
* get the cpu usage
*/
static ms_s08 mspmc_innerapi_netDev(NETCARDInfo *ms_in pnetcard_info,NETInfo * ms_out pnet_info)
{
	ms_bufcheckRetDes(-1, pnetcard_info,"param## pnetcard_info");
	ms_bufcheckRetDes(-1, pnet_info,"param## pnet_info");

#if defined(OS_LINUX_SOC)
#define enable_dbg_netdev ms_false

	char s[512]={0};
	ms_u08 eth_index=0;
	fseek( msfp_netdev, 0, SEEK_SET );
	while (fgets(s, 512, msfp_netdev)) {
		ms_enVerbose(enable_dbg_netdev,"------------%s",s);
		if( ms_strncmp_seq(s,"Inter-|") ||ms_strncmp_seq(s,"face")){
			ms_enVerbose(enable_dbg_netdev,"ignor it");
			continue;
		}
		if( NETDEV_DISABLE_LO&&ms_strncmp_seq(s,"lo")){
			ms_enVerbose(enable_dbg_netdev,"ignor it");
			continue;
		}
		ms_u08 name[msnet_maxlen_ifname]={0};
		NETDATAInfo rx_netdata_info;
		NETDATAInfo tx_netdata_info;
		sscanf(s, "%s	%Lu	%Lu	%Lu	%Lu	%Lu	%Lu	%Lu	%Lu	%Lu	%Lu	%Lu	%Lu	%Lu	%Lu	%Lu	%Lu", 
			&name, 
			&rx_netdata_info.bytes, 
			&rx_netdata_info.packets, 
			&rx_netdata_info.errs, 
			&rx_netdata_info.drop, 
			&rx_netdata_info.fifo, 
			&rx_netdata_info.frame_colls, 
			&rx_netdata_info.compressed_carrier, 
			&rx_netdata_info.multicast_compressed, 
			&tx_netdata_info.bytes, 
			&tx_netdata_info.packets, 
			&tx_netdata_info.errs, 
			&tx_netdata_info.drop, 
			&tx_netdata_info.fifo, 
			&tx_netdata_info.frame_colls, 
			&tx_netdata_info.compressed_carrier, 
			&tx_netdata_info.multicast_compressed
		);
		//去掉结尾的":"
		name[ms_buflen(name)-1]=0;
		ms_enVerbose(enable_dbg_netdev,"update:%s",name);
		for(eth_index=0;eth_index<(pnetcard_info->num+1);eth_index++){
			ms_enVerbose(enable_dbg_netdev,"-----interfacename,name: %s,%s",pnetcard_info->cfg_info[eth_index].name,name);
			if( ms_strncmp_saeq(name,pnetcard_info->cfg_info[eth_index].name) ){
				ms_memcpy(&pnet_info->rx_netdata_info[eth_index], &rx_netdata_info, ms_bufsize(NETDATAInfo));
				ms_memcpy(&pnet_info->tx_netdata_info[eth_index], &tx_netdata_info, ms_bufsize(NETDATAInfo));
				ms_enVerbose(enable_dbg_netdev,"[%s]rx-%lld, %lld,%lld, %lld", 
					pnetcard_info->cfg_info[eth_index].name,
					pnet_info->rx_netdata_info[eth_index].bytes,pnet_info->rx_netdata_info[eth_index].packets,
					pnet_info->rx_netdata_info[eth_index].errs,pnet_info->rx_netdata_info[eth_index].drop);
				ms_enVerbose(enable_dbg_netdev,"[%s]tx-%lld, %lld,%lld, %lld", 
					pnetcard_info->cfg_info[eth_index].name,
					pnet_info->tx_netdata_info[eth_index].bytes,pnet_info->tx_netdata_info[eth_index].packets,
					pnet_info->tx_netdata_info[eth_index].errs,pnet_info->tx_netdata_info[eth_index].drop);
				break;
			}
		}
	}
#else
	ms_funcNosupports;
#endif
	return 0;
}

static ms_bool mspmc_innerapi_isLittleEndian(ms_void )
{
	static ms_s32 little_endian_check = -1;
	if(little_endian_check == -1) {
		union {
			ms_s32 i;
			ms_s08 c;
		} little_check_union;
		little_check_union.i = 0x01;
		little_endian_check = little_check_union.c;
	}
	return (little_endian_check == 1) ? ms_true : ms_false;
}

static ms_bool mspmc_innerapi_isSuperUser(ms_void )
{
#if defined(OS_LINUX_SOC)
	if( getuid() == 0 ){
		ms_verbose("Run as superuser");
		return ms_true;
	}
#else
	ms_funcNosupports;
#endif
	return ms_false;
}
static ms_bool mspmc_innerapi_isInDocker(ms_void )
{
	ms_byte cmd[1024]={0};
	ms_strcpy(cmd, "egrep  '^1:.+(docker|lxc|kubepods)' /proc/1/cgroup");
	return ms_cmdRet(cmd);
}
static ms_s08 mspmc_innerapi_memInfo(MEMInfo * ms_out pmem_info)
{
	ms_bufcheckRetDes(-1, pmem_info,"param## pmem_info");
#if defined(OS_LINUX_SOC)
	char s[512];
	fseek( fp_meminfo, 0, SEEK_SET );
	while (fgets(s, 512, fp_meminfo)) {
		if(ms_strncmp_seq(s, "MemTotal:")){
			sscanf(s,"MemTotal: %d kB", &pmem_info->total);
		}else if(ms_strncmp_seq(s, "MemFree:")){
			sscanf(s,"MemFree: %d kB", &pmem_info->free);
		}else if(ms_strncmp_seq(s, "MemAvailable:")){
			sscanf(s,"MemAvailable: %d kB", &pmem_info->available);
		}else if(ms_strncmp_seq(s, "Buffers:")){
			sscanf(s,"Buffers: %d kB", &pmem_info->buff);
		}else if(ms_strncmp_seq(s, "Cached:")){
			sscanf(s,"Cached: %d kB", &pmem_info->cache);
		}else if(ms_strncmp_seq(s, "SwapTotal:")){
			sscanf(s,"SwapTotal: %d kB", &pmem_info->swaptotal);
		}else if(ms_strncmp_seq(s, "SwapFree:")){
			sscanf(s,"SwapFree: %d kB", &pmem_info->swapfree);
		}else if(ms_strncmp_seq(s, "Shmem:")){
			sscanf(s,"Shmem: %d kB", &pmem_info->shared);
		}
	}
#else
	ms_funcNosupports;
#endif
	return 0;
}

static char mspmc_innerapi_netExternInfo(NETCARDInfo *pnetcard_info,NETInfo *pnet_info)//must be call after mspmc_innerapi_HWNetcardInfo()
{
	ms_bufcheckRetDes(-1, pnetcard_info,"param## pnetcard_info");
	ms_bufcheckRetDes(-1, pnet_info,"param## pnet_info");
	if(1!=pnetcard_info->isinit){
		ms_errRet (-1, "Must be call after mspmc_innerapi_HWNetcardInfo()");
	}
	int eth_index=0;
	for(eth_index=0;eth_index<(pnetcard_info->num+1);eth_index++){
		NETInfo net_info_tmp;
		ms_stru0(&net_info_tmp, NETInfo);
		int ret=msethtool_api_getInfo(
			pnetcard_info->cfg_info[eth_index].name, 
			&net_info_tmp.speed[eth_index],  
			&net_info_tmp.duplex[eth_index] , 
			&net_info_tmp.autoneg[eth_index] , 
			&net_info_tmp.is_linkup[eth_index]) ;
		if(ret<0){
			pnet_info->is_linkup[eth_index]	=0;
			pnet_info->speed[eth_index]		=-1;
		}else{
			//初始化第一次不记录
			ms_bool flag_firstinit=(0==pnet_info->speed[eth_index]
				&&0==pnet_info->duplex[eth_index]
				&&0==pnet_info->autoneg[eth_index]
				&&0==pnet_info->is_linkup[eth_index]) ? ms_true : ms_false;
			if((ms_false==flag_firstinit)
				&&(pnet_info->speed[eth_index]!=net_info_tmp.speed[eth_index]
					|pnet_info->duplex[eth_index]!=net_info_tmp.duplex[eth_index]
					|pnet_info->autoneg[eth_index]!=net_info_tmp.autoneg[eth_index]
					|pnet_info->is_linkup[eth_index]!=net_info_tmp.is_linkup[eth_index])
			){
				ms_byte srcJson[1024]={0};
				ms_sprintfs(srcJson, "{\""EVENT_DATA_DES"\":\"%s network card information changes. "
					"The original (speed,duplex,autoneg,is_linkup) information is %d,%d,%d,%d, "
					"and now is %d,%d,%d,%d\"}", pnetcard_info->cfg_info[eth_index].name,
					pnet_info->speed[eth_index],pnet_info->duplex[eth_index],
					pnet_info->autoneg[eth_index],pnet_info->is_linkup[eth_index],
					net_info_tmp.speed[eth_index],net_info_tmp.duplex[eth_index],
					net_info_tmp.autoneg[eth_index],net_info_tmp.is_linkup[eth_index]);
				msevp_api_eventIn2( eventType_nicException, MSEVP_DEFAULT_DEVID, srcJson);
			}
			pnet_info->speed[eth_index]=net_info_tmp.speed[eth_index];
			pnet_info->duplex[eth_index]=net_info_tmp.duplex[eth_index];
			pnet_info->autoneg[eth_index]=net_info_tmp.autoneg[eth_index];
			pnet_info->is_linkup[eth_index]=net_info_tmp.is_linkup[eth_index];
		}
	}
	return 0;
}
ms_s08 mspmc_innerapi_pciDevInfo(PCIDEVInfo *pcidevinfo)  
{  
	if(ms_false==msmd_api_isInstallByBin("lspci")){
		return -1;
	}
	ms_system("lspci  > /tmp/lspci_info");
	char s[512]={0};
	FILE *fdisk_lspci_info= fopen("/tmp/lspci_info", "r");
	if(ms_null==fdisk_lspci_info){
		ms_errRet(-1,"Open  /tmp/lspci_info failed");
	}
	fseek( fdisk_lspci_info, 0, SEEK_SET );
	while (fgets(s, 512, fdisk_lspci_info)) {
		ms_string  str_array[16];
		//ms_debug("[lspci]:%s",str_array_ret[item_index]);
		if(msstr_api_split(s, ":", str_array)>1){
			//ms_debug("[lspci]:%s",str_array[1]);
			if(ms_true==msstr_api_isCasestr(str_array[1],"VGA compatible controller")){
				ms_strcpy(pcidevinfo->vgainfo, str_array[2]);
			}else if(ms_true==msstr_api_isCasestr(str_array[1],"SCSI storage controller")){
				ms_strcpy(pcidevinfo->SCSIstorageinfo[pcidevinfo->num_SCSIstorage], str_array[2]);
				pcidevinfo->num_SCSIstorage+=1;
			}else if(ms_true==msstr_api_isCasestr(str_array[1],"SATA controller")){
				ms_strcpy(pcidevinfo->satainfo[pcidevinfo->num_sata], str_array[2]);
				pcidevinfo->num_sata+=1;
			}else if(ms_true==msstr_api_isCasestr(str_array[1],"Memory controller")){
				ms_strcpy(pcidevinfo->meminfo, str_array[2]);
			}else if(ms_true==msstr_api_isCasestr(str_array[1],"Audio device")){
				ms_strcpy(pcidevinfo->audioinfo, str_array[2]);
			}else if(ms_true==msstr_api_isCasestr(str_array[1],"Ethernet controller")){
				ms_strcpy(pcidevinfo->ethnetinfo[pcidevinfo->num_ethnet], str_array[2]);
				pcidevinfo->num_ethnet+=1;
			}else if(ms_true==msstr_api_isCasestr(str_array[1],"SD Host controller")){
				ms_strcpy(pcidevinfo->sdhostinfo, str_array[2]);
			}else if(ms_true==msstr_api_isCasestr(str_array[1],"Network controller")){
				ms_strcpy(pcidevinfo->netinfo[pcidevinfo->num_net], str_array[2]);
				pcidevinfo->num_net+=1;
			}else if(ms_true==msstr_api_isCasestr(str_array[1],"Serial bus controller")){
				ms_strcpy(pcidevinfo->serialbusinfo, str_array[2]);
			}
		}	
	}
	fclose(fdisk_lspci_info);
	return 0;
}
char mspmc_innerapi_HWNetcardInfo(NETCARDInfo *pnetcard_info)
{
#if defined(OS_LINUX_SOC)
	ms_bufcheckRet(-1, pnetcard_info);
	char s[512]={0};
	ms_string delim = " \t\n:";
	ms_string token  = ms_null;
	ms_u08 eth_index=0;
	fseek( msfp_netdev, 0, SEEK_SET );
	pnetcard_info->num=0;
	pnetcard_info->ppp_num=0;
	while (fgets(s, 512, msfp_netdev)) {
		 token  = strtok(s, delim);
		ms_enDbg(0,"------------%s,%s",token,s);
		if( ms_strncmp_saeq(token,"Inter-|") ||ms_strncmp_saeq(token,"face")||ms_strncmp_seq(token,"virbr")){
			continue;
		}
		if(ms_strncmp_saeq(token,"lo")){
			continue;
		}
		if(ms_strncmp_seq(token,"ppp")){
			pnetcard_info->ppp_num+=1;
			continue;
		}
		if(ms_strncmp_seq(token,"docker")){
			continue;
		}
		NETCFGInfo *pnetcfg_info=(NETCFGInfo *)&pnetcard_info->cfg_info[pnetcard_info->num];
		if(ms_strncmp_seq(token,"wlp")){
			pnetcfg_info->flag_wifi=ms_true;
		}
//Get name	
		//pnetcard_info->cfg_info[pnetcard_info->num].id=0x88888888+eth_index;
		ms_strcpy(pnetcfg_info->name,token);
//Get mac	
		msnet_api_getIfaceMac_string(pnetcfg_info->name, pnetcfg_info->address, sizeof(pnetcfg_info->address));
//Get mtu	
		msnet_api_getIfaceMtu(pnetcfg_info->name, pnetcfg_info->mtu, sizeof(pnetcfg_info->mtu));
//Get ipaddr,netmask				
		 msnet_api_getIfaceInfo(pnetcfg_info);
//Get num	 
		 pnetcard_info->num+=1;
		if(pnetcard_info->num>msnet_maxnum_iface){
			ms_waring("Only support %d num_iface,force set num_iface from %d to %d", msnet_maxnum_iface,pnetcard_info->num, msnet_maxnum_iface);
			pnetcard_info->num=msnet_maxnum_iface;
			goto ms_end;
		}	
	}
//将lo放到最后面，不计入网卡数量
	if( ms_false==NETDEV_DISABLE_LO){
		fseek( msfp_netdev, 0, SEEK_SET );
		while (fgets(s, 512, msfp_netdev)) {
			token= strtok(s, delim);
			ms_enDbg(0,"------------%s,%s",token,s);
			if( !ms_strncmp_saeq(token,"lo")){
				continue;
			}
			NETCFGInfo *pnetcfg_info=(NETCFGInfo *)&pnetcard_info->cfg_info[pnetcard_info->num];
	//Get name	
			//pnetcard_info->cfg_info[pnetcard_info->num].id=0x88888888+eth_index;
			ms_strcpy(pnetcfg_info->name,token);
	//Get mac	
			msnet_api_getIfaceMac_string(pnetcfg_info->name, pnetcfg_info->address, sizeof(pnetcfg_info->address));
	//Get mtu	
			msnet_api_getIfaceMtu(pnetcfg_info->name, pnetcfg_info->mtu, sizeof(pnetcfg_info->mtu));
	//Get ipaddr,netmask				
			msnet_api_getIfaceInfo(pnetcfg_info);
			break;
		}
	}
#else
	ms_funcNosupports;
#endif
ms_end:
	pnetcard_info->isinit=1;
	return 0;
}

static char mspmc_innerapi_HWCpuInfo(CPUHWInfo*pcpuhw_info)
{
	char ret=0;
#if defined(OS_LINUX_SOC)
	ms_bufcheckRetDes(-1, pcpuhw_info,"param## pcpuhw_info");
	char s[512];
	FILE *fp_cpuinfo= fopen("/proc/cpuinfo", "r");
	if(ms_null==fp_cpuinfo){
		ms_errRet(-1,"open (/proc/cpuinfo) failed");
	}
	fseek( fp_cpuinfo, 0, SEEK_SET );
	ms_bool find_processor=ms_false;
	ms_string  str_array[8];
	//ms_verbose("find_processor--%d",find_processor);
	while (fgets(s, 512, fp_cpuinfo)) {
		//ms_verbose("--%s",s);
		if(msstr_api_isCasestr_IgnoreLetterCase(s,"processor")){
			if(ms_false==find_processor){
				find_processor=ms_true;
				//ms_verbose("find processor--%d",find_processor);
			}else{
				//ms_verbose("find end--%d",find_processor);
				goto ms_end;
			}
		}else if(msstr_api_isCasestr_IgnoreLetterCase(s,"Processor")||msstr_api_isCasestr_IgnoreLetterCase(s,"model name")){
			//ms_verbose("find Processor");
			if(msstr_api_split(s, ":", str_array)>1){
				ms_strcpy(pcpuhw_info->modelname,str_array[1]);
				//ms_verbose("--modelname:%s",pcpuhw_info->modelname);
			}
		}
	#if defined OS_PLATFORM_ARMV7L ||defined OS_PLATFORM_ARM64
		else if(msstr_api_isCasestr_IgnoreLetterCase(s,"BogoMIPS")		){
			//ms_verbose("find BogoMIPS");
			if(msstr_api_split(s, ":", str_array)>1){
				ms_strcpy(pcpuhw_info->bogomips,str_array[1]);
				//ms_verbose("--bogomips:%s",pcpuhw_info->bogomips);
			}
		}
	#else
		else if(msstr_api_isCasestr_IgnoreLetterCase(s,"cache size")	){
			if(msstr_api_split(s, ":", str_array)>1){
				pcpuhw_info->cachesize=atoi(str_array[1]);
			}
		}else if(msstr_api_isCasestr_IgnoreLetterCase(s,"siblings")		){
			if(msstr_api_split(s, ":", str_array)>1){
				pcpuhw_info->siblings=atoi(str_array[1]);
			}
		}else if(msstr_api_isCasestr_IgnoreLetterCase(s,"cpu cores")		){
			if(msstr_api_split(s, ":", str_array)>1){
				pcpuhw_info->cpucores=atoi(str_array[1]);
			}
		}else if(msstr_api_isCasestr_IgnoreLetterCase(s,"clflush size")	){
			if(msstr_api_split(s, ":", str_array)>1){
				pcpuhw_info->clflushsize=atoi(str_array[1]);
			}
		}
	#endif
	}
ms_end:	
//由于授权需要modelname，所以此处进行赋值
	if(0==ms_buflen(pcpuhw_info->modelname) ){
		ms_strcpy(pcpuhw_info->modelname,"unknow");
	}
	fclose(fp_cpuinfo);
#else
	ms_funcNosupports;
#endif
	return ret;
}

static char mspmc_innerapi_HWInfo(HARDWAREInfo *phardware_info)
{
	ms_bufcheckRetDes(-1, phardware_info,"param## phardware_info");
ms_verbose("Get cpu info");
	if(mspmc_innerapi_HWCpuInfo(&phardware_info->cpuhw_info)<0){
		ms_errRet(-1,"Get hwcpuinfo error");
	}
ms_verbose("Get netcard info");
	if(mspmc_innerapi_HWNetcardInfo(&phardware_info->netcard_info)<0){
		ms_errRet(-1,"Get hwnetcardinfo error");
	}
ms_verbose("Get dmidecode info");
	mspmc_innerapi_HWDmiDecode(phardware_info->dmidecode_info,maxlen_dmidecode_info);
	//ms_verbose("%s",phardware_info->dmidecode_info);
ms_verbose("Get systemuuid");
	mspmc_innerapi_HWSysUUID(phardware_info->systemuuid,maxlen_systemuuid);
	//ms_verbose("%s",phardware_info->systemuuid);
ms_verbose("Get processorid");	
	mspmc_innerapi_HWProcessorID(phardware_info->processorid,maxlen_processorid);
	//ms_verbose("%s",phardware_info->processorid);
ms_verbose("Get hwdisk info");
	mspmc_innerapi_HWDiskInfo(phardware_info);
ms_verbose("Get blk serial sda");	
	mspmc_innerapi_HWBlkinfoSerialsda(phardware_info->blk_info_serialsda,maxlen_blkserial_info );
	//ms_verbose("%s",phardware_info->blk_info_serialsda);
ms_verbose("Get pcidev info");
	mspmc_innerapi_pciDevInfo(&phardware_info->pcidevinfo);
	return 0;
}
static char mspmc_innerapi_OSInfo(OSInfo *posinfo)
{
	ms_bufcheckRetDes(-1, posinfo,"param## posinfo");
#if defined(OS_LINUX_SOC)
	ms_bufcheckRet(-1, posinfo);
	struct utsname name;
	char	buf[2048]={0};
	int	i,j,k=0,flag=0;/*i,j for argv,k for buf,flag for error*/

	if(uname(&name)<0){
		ms_errRet(-1,"uname error");
	}
	posinfo->is_littleendian=mspmc_innerapi_isLittleEndian( );
	posinfo->is_supperuser=mspmc_innerapi_isSuperUser( );
	posinfo->is_inDocker=mspmc_innerapi_isInDocker();
	ms_strcpy(posinfo->sysname,name.sysname);
	ms_strcpy(posinfo->nodename,name.nodename);
	ms_strcpy(posinfo->release,name.release);
	ms_verbose("Get release info");
	unsigned char release_info[1024];
	if(ms_cmdRead("cat /etc/os-release",release_info , sizeof(release_info))>0){
		unsigned char pretty_name[512];
		ms_cmdRead("cat /etc/os-release | grep PRETTY_NAME=",pretty_name , sizeof(pretty_name));
		ms_strcpy(posinfo->version, &pretty_name[ms_buflen("PRETTY_NAME=")]);
		if(msstr_api_isCasestr(release_info, "ubuntu")){
			if(msstr_api_isCasestr(release_info, "16.04")){
				posinfo->ossystem=ossys_debain_ubuntu1604;
			}else if(msstr_api_isCasestr(release_info, "18.04")){
				posinfo->ossystem=ossys_debain_ubuntu1804;
			}else if(msstr_api_isCasestr(release_info, "20.04")){
				posinfo->ossystem=ossys_debain_ubuntu2004;
			}else if(msstr_api_isCasestr(release_info, "22.04")){
				posinfo->ossystem=ossys_debain_ubuntu2204;
			}else{
				posinfo->ossystem=ossys_debain_ubuntu;
			}
		}else if(msstr_api_isCasestr(release_info, "Deepin")){
			posinfo->ossystem=ossys_debain_deepin;
		}else if(msstr_api_isCasestr(release_info, "uos")){
			posinfo->ossystem=ossys_debain_uos20;
		}else if(msstr_api_isCasestr(release_info, "centos")){
			posinfo->ossystem=ossys_rhel_centos;
		}else if(msstr_api_isCasestr(release_info, "kylin")){
			posinfo->ossystem=ossys_rhel_kylin;
		}else if(msstr_api_isCasestr(release_info, "neokylin")){
			posinfo->ossystem=ossys_rhel_neokylin;
		}
	}
	if(0==ms_buflen(posinfo->version)){
		posinfo->ossystem=ossys_linux;
		ms_strcpy(posinfo->version,name.version);
	}
	ms_strcpy(posinfo->machine,name.machine);
	ms_s08 strCurDTime[64]={0};
	ms_sprintfs(posinfo->server_starttime, "%s",mstime_api_curDTime(mstime_fmt_datetime,strCurDTime));
	
	ms_verbose("Get limit info");
	if(0!= getrlimit(RLIMIT_STACK, (struct rlimit *)&posinfo->stack_size)){
		ms_errRet(-1,"getrlimit RLIMIT_STACK error");
	}
	if(0!= getrlimit(RLIMIT_NPROC, (struct rlimit *)&posinfo->max_user_processes)){
		ms_errRet(-1,"getrlimit RLIMIT_NPROC error");
	}
	if(0!= getrlimit(RLIMIT_NOFILE, (struct rlimit *)&posinfo->max_open_files)){
		ms_errRet(-1,"getrlimit RLIMIT_NOFILE error");
	}
	if(0!= getrlimit(RLIMIT_CPU, (struct rlimit *)&posinfo->time_cpu)){
		ms_errRet(-1,"getrlimit RLIMIT_CPU error");
	}
	if(0!= getrlimit(RLIMIT_DATA, (struct rlimit *)&posinfo->data_seg)){
		ms_errRet(-1,"getrlimit RLIMIT_DATA error");
	}
	if(0!= getrlimit(RLIMIT_FSIZE, (struct rlimit *)&posinfo->file_size)){
		ms_errRet(-1,"getrlimit RLIMIT_FSIZE error");
	}

	posinfo->flag_aarchCheckPass=msmd_api_checkVarTypeLen(posinfo->aarchCheck,posinfo->aarchCheck_exinfo);
#if 0
	ms_verbose("Check safenet");
	char cmdline[512]={0};
	ms_sprintfs(cmdline,"mkdir  -p /var/log/mscore/ && wget http://127.0.0.1:1947 -O /var/log/mscore/safenet_index.xml  -o  /var/log/mscore/safenet_wgeinfo");
	posinfo->has_safenetdriver=ms_cmdRet(cmdline);

	ms_verbose("Get route and dns info");
	unsigned char   route_default[512]={0};
	unsigned char   dnsinfo[512]={0};
	ms_cmdRead("route | grep default", route_default, sizeof(route_default));
	ms_cmdRead("cat /etc/resolv.conf | grep nameserver", dnsinfo, sizeof(dnsinfo));
	int index=0;
	for(index=0;index<ms_buflen(route_default);index++){
		//ms_waring("route_default:%c-%d", route_default[index], route_default[index]);
	}
	for(index=0;index<ms_buflen(dnsinfo);index++){
		//ms_waring("dnsinfo:%c-%d", dnsinfo[index], dnsinfo[index]);
	}
#endif
#else
	ms_funcNosupports;
#endif
	return 0;
}

static ms_void mspmc_innerapi_mntPointInfo(DISKInfo *pdiskinfo) {
	struct statfs st;
	MOUNTInfo *pmount_info=&pdiskinfo->mount_info[pdiskinfo->mountpoint_num];
	if (statfs(pmount_info->mntpoint, &st) < 0) {
		ms_errNoret("%s: %s", pmount_info->mntpoint, strerror(errno));
	} else {
		if (st.f_blocks == 0){
			return;
		}
#if 0		
		//Get blkinfo
		if(ms_true==msmd_api_isInstallByBin("blkid")){
			ms_byte cmdline[1024]={0};
			ms_sprintfs(cmdline, "blkid | grep \"%s\"", pmount_info->dev);
			ms_debug("cmdline:%s",cmdline);
			ms_cmdRead(cmdline, pmount_info->blkinfo, sizeof(pmount_info->blkinfo)-1);
		}
#endif
		//Get size
		pmount_info->dtotal=(long long)st.f_blocks * (long long)st.f_bsize;
		pmount_info->dfree=(long long)st.f_bfree * (long long)st.f_bsize;
		pmount_info->dused=pmount_info->dtotal-pmount_info->dfree;
		//Calac mountpoint_num
		pdiskinfo->mountpoint_num +=1;
		if(pdiskinfo->mountpoint_num>mscfg_maxnum_partiton){
			ms_waring("Only support %d mountpoint,force set mountpoint_num from %d to %d", mscfg_maxnum_partiton,pdiskinfo->mountpoint_num, mscfg_maxnum_partiton);
			pdiskinfo->mountpoint_num=mscfg_maxnum_partiton;
			return;
		}
	}
}

static char mspmc_innerapi_diskInfo(DISKInfo *pdiskinfo)
{
	ms_bufcheckRetDes(-1, pdiskinfo,"param## pdiskinfo");
	char s[2048];
	memset(pdiskinfo,0,sizeof(DISKInfo));
	fseek( fp_mounts, 0, SEEK_SET );
	while (fgets(s, 2048, fp_mounts)) {
#if 0		
		if(ms_false==msstr_api_isCasestr(s,"/dev/sd")
			||ms_true==msstr_api_isCasestr(s,"/dev/loop")){
			continue;
		}
#else
		if(ms_true==msstr_api_isCasestr(s,"/dev/loop")){
			continue;
		}
#endif
		char type[128];
		int tem1;
		int tem2;
		MOUNTInfo *pmount_info=&pdiskinfo->mount_info[pdiskinfo->mountpoint_num];
		sscanf(s,"%s %s %s %s %d %d", &pmount_info->dev, &pmount_info->mntpoint,&type,&pmount_info->mntinfo,&tem1,&tem2);
		//ms_debug("mountpath:%s,dev:%s",pmount_info->mntpoint,pmount_info->dev);
		mspmc_innerapi_mntPointInfo(pdiskinfo);
	}
	return 0;
}
ms_void mspmc_innerapi_checkSystemInfo(void (*waring_func)(),ms_bool flag_disable_checkmem,ms_bool flag_disable_checkdisk,ms_bool flag_disable_checkcpu)
{	
	#define MAX_CPU_USAGE		92
	#define MIN_MEM_AVAILABLE	(50*1024)
	#define MIN_DISK_AVAILABLE	(500*ms_mb)
	CPUInfo *pcpu_info	=&sysperform_info.cpu_info;
	MEMInfo *pmem_info=&sysperform_info.mem_info;
	NETInfo *pnet_info=&sysperform_info.net_info;
	DISKInfo	*pdisk_info=&sysperform_info.disk_info;
	
	char str_runinfo[1024]={0};
	ms_sprintfs(str_runinfo,"btime=%lld;procs_running=%lld;procs_blocked=%lld",pcpu_info->btime,pcpu_info->procs_running,pcpu_info->procs_blocked) ;
	char tbuf[2048]={0};
	if(ms_false==flag_disable_checkcpu){
		char cpu_waring[2048]={0};
		if(pcpu_info->usage[0]>MAX_CPU_USAGE){
			ms_strcats(tbuf, cpu_waring,"cpu_usage(%f);", pcpu_info->usage[0]);
		}else{
			ms_strcats(tbuf, str_runinfo,",cpu_usage(%f)", pcpu_info->usage[0]);
		}
		unsigned char cpu_index=0;
		for(cpu_index=0;cpu_index<pcpu_info->num;cpu_index++){
			if(pcpu_info->usage[(cpu_index+1)]>MAX_CPU_USAGE){
				ms_strcats(tbuf, cpu_waring, "cpu%d_usage(%f);", cpu_index,pcpu_info->usage[(cpu_index+1)]);
			}
		}
		if(ms_buflen(cpu_waring)>0){
			if(ms_null!=waring_func){waring_func();}
			static ms_u64 mstime_cpu=0;
			if(ms_true== msmd_api_timeToSave(&mstime_cpu)){
				ms_sprintfs(tbuf, "{\""EVENT_DATA_DES"\":\"%s,cpuload is too large:%s\"}", str_runinfo,cpu_waring);
				msevp_api_eventIn2( eventType_cpuLoadException, MSEVP_DEFAULT_DEVID, tbuf);
			}
		}
	}
	
	if(ms_false==flag_disable_checkmem){
		if( ((pmem_info->free/(pmem_info->total/10))<1)
			||(  (pmem_info->free<300000)
				&&(pmem_info->available>pmem_info->free)
				&&((pmem_info->available-pmem_info->free)*100/pmem_info->total)>30)
		){
			
			static ms_u64 mstime_mem=0;
			if(ms_true== msmd_api_timeToSave(&mstime_mem)){
				ms_sprintfs(tbuf, "{\""EVENT_DATA_DES"\":\"%s,mem available is too small(cache,free,available,total:%u,%u,%u,%u),will try to clean\"}", 
					str_runinfo,pmem_info->cache,pmem_info->free,pmem_info->available,pmem_info->total);
				msevp_api_eventIn2(eventType_memException, MSEVP_DEFAULT_DEVID, tbuf);
			}
			if(ms_null!=waring_func){waring_func();}

			//will try to clean
			msmd_api_clearCache(memclear_all);
		}
	}
	if(ms_false==flag_disable_checkdisk){
		unsigned char disk_index=0;
		for(disk_index=0;disk_index<pdisk_info->mountpoint_num;disk_index++){
			MOUNTInfo *pmount_info=&pdisk_info->mount_info[disk_index];
			if(ms_strncmp_saeq(pmount_info->mntpoint, "/")){
				if(pmount_info->dfree<MIN_DISK_AVAILABLE){
					static ms_u64 mstime_disk=0;
					if(ms_true== msmd_api_timeToSave(&mstime_disk)){
						ms_sprintfs(tbuf, "{\""EVENT_DATA_DES"\":\"%s,disk available(%s/%s) is too small,will try to clear system , app and kernel logs\"}", 
							str_runinfo,ms_num2str(pmount_info->dfree),ms_num2str(pmount_info->dtotal));
						msevp_api_eventIn2( eventType_diskException, MSEVP_DEFAULT_DEVID, tbuf);
					}
					if(ms_null!=waring_func){waring_func();}
					
					//will try to clean
					msmd_api_clearSysLog();
					msmd_api_clearAppLog();
					msmd_api_cleanKernelUpgradeFile();
				}
				break;
			}
		}
	}
}
char mspmc_api_init(ms_void )
{
	if(0!=flag_mspmc_init){
		return 0;
	}
	ms_verbose("Open proc files,like:meminfo,dev,stat,diskstats,mounts...");
	fp_meminfo = fopen("/proc/meminfo", "r");
	if(ms_null==fp_meminfo){
		ms_errRet(-1,"Open /proc/meminfo failed");
	}

	msfp_netdev = fopen("/proc/net/dev", "r");
	if(ms_null==msfp_netdev){
		ms_errRet(-1,"Open /proc/net/dev failed");
	}

	fp_stat = fopen("/proc/stat", "r");
	if(ms_null==fp_stat){
		ms_errRet(-1,"Open /proc/stat failed");
	}
	fp_diskstats = fopen("/proc/diskstats", "r");
	if(ms_null==fp_diskstats){
		ms_errRet(-1,"Open /proc/diskstats failed");
	}
	fp_mounts= fopen("/proc/mounts", "r");
	if(ms_null==fp_mounts){
		ms_errRet(-1,"Open /proc/mounts failed");
	}
	flag_mspmc_init=ms_true;
	
	ms_verbose("Get osinfo(once),hardwareinfo(once), init sysperform_info(more)");
	memset(&os_info,0,sizeof(OSInfo));
	memset(&hardware_info,0,sizeof(HARDWAREInfo));
	memset(&sysperform_info,0,sizeof(SYSPERFORMInfo));
	
	ms_verbose("Get os info");
	if(mspmc_innerapi_OSInfo(&os_info)<0){
		ms_errRet(-1,"Get osinfo error");
	}
	ms_verbose("Get hardware info");
	if(mspmc_innerapi_HWInfo(&hardware_info)<0){
		ms_errRet(-1,"Get hardwareinfo error");
	}
	ms_verbose("do msperformance");
	if(mspmc_api_run(&sysperform_info,&hardware_info.netcard_info,ms_null,ms_false,ms_false,ms_false,ms_false)<0){
		ms_errRet(-1,"Done performance init failed");
	}
	return 0;
}

char mspmc_api_run(SYSPERFORMInfo *sysperform_info,NETCARDInfo *pnetcard_info,void (*waring_func)(void),
	ms_bool flag_disable_checknet,ms_bool flag_disable_checkmem,ms_bool flag_disable_checkdisk,ms_bool flag_disable_checkcpu)
{
	if(ms_true!=flag_mspmc_init){
		ms_errRet (-1, "Must be call mspmc_api_init first");
		return -1;
	}
	ms_bufcheckRetDes(-1, sysperform_info,"sysperform_info");
	ms_bufcheckRetDes(-1, pnetcard_info,"pnetcard_info");
#if defined(OS_LINUX_SOC)

	//ms_verbose("get meminfo");
	if((ms_false==flag_disable_checkmem) && (mspmc_innerapi_memInfo(&sysperform_info->mem_info)<0)){
		ms_errRet (-1, "Get meminfo error");
	}
	//ms_verbose("get diskinfo");
	if((ms_false==flag_disable_checkdisk) && (mspmc_innerapi_diskInfo(&sysperform_info->disk_info)<0)){
		ms_errRet (-1, "Get diskinfo error");
	}

	int ret_netdev1=0;
	NETInfo net_info1;
	NETInfo net_info2;
	NETInfo *pnet_info=&sysperform_info->net_info;
	if(ms_false==flag_disable_checknet){
		//ms_verbose("get network");
		if(  mspmc_api_netInfo(pnetcard_info)<0){
			ms_errRet(-1,"Get mspmc_api_netInfo error");
		}
		//ms_verbose("get netexterninfo");
		if(  mspmc_innerapi_netExternInfo(pnetcard_info,pnet_info)<0){
			ms_errRet (-1, "Get netexterninfo error");
		}
		memset(&net_info1, 0, sizeof(NETInfo));
		memset(&net_info2, 0, sizeof(NETInfo));
		//ms_verbose("get netdev");
		ret_netdev1=mspmc_innerapi_netDev(pnetcard_info,&net_info1);
		if(ret_netdev1<0){
			ms_errRet(-1, "Get netdev1 error");
		}
	}
	
	int ret_stat1=0;
	STATInfo stat_info1[64]={0};
	CPUInfo *pcpu_info=&sysperform_info->cpu_info;
	if(ms_false==flag_disable_checkcpu){
		//ms_verbose("get cpunum");
		pcpu_info->num = msmd_api_getCpuNum();
		memset(stat_info1,0,sizeof(stat_info1));
		//ms_verbose("get cpustat");
		ret_stat1=mspmc_innerapi_cpuStat(pcpu_info,stat_info1);
		if(ret_stat1<0){
			ms_errRet(-1, "Get cpustat1 error");
		}
	}
	if((0!=ret_netdev1&&0!=ret_stat1)){
		return -1;
	}
	
	ms_sleep(1);
	
	if((ms_false==flag_disable_checknet)&&(0==ret_netdev1)){
		//ms_verbose("get netdev");
		if(0==mspmc_innerapi_netDev(pnetcard_info,&net_info2)){
			//ms_verbose("get rx_netdata_info and tx_netdata_info");
			memcpy(pnet_info->rx_netdata_info,net_info2.rx_netdata_info,sizeof(NETDATAInfo)*msnet_maxnum_iface);
			memcpy(pnet_info->tx_netdata_info,net_info2.tx_netdata_info,sizeof(NETDATAInfo)*msnet_maxnum_iface);
			//ms_verbose("get rate");
			unsigned int eth_index=0;
			for(eth_index=0;eth_index<(pnetcard_info->num+1);eth_index++){
				pnet_info->rx_netdata_info[eth_index].rate=net_info2.rx_netdata_info[eth_index].bytes-net_info1.rx_netdata_info[eth_index].bytes;
				pnet_info->tx_netdata_info[eth_index].rate=net_info2.tx_netdata_info[eth_index].bytes-net_info1.tx_netdata_info[eth_index].bytes;
				char buffer[1024]={0};
			}
		}else{
			ms_errRet(-1, "Get netdev2 error");
		}
	}
	if((ms_false==flag_disable_checkcpu)&&(0==ret_stat1)){
		STATInfo stat_info2[64];
		memset(stat_info2,0,sizeof(stat_info2));
		//ms_verbose("get cpustat");
		if(0==mspmc_innerapi_cpuStat(pcpu_info,stat_info2)){
			int cpu_index=0;
			for(cpu_index=0;cpu_index<(pcpu_info->num+1);cpu_index++){
				MS_U64 idle = stat_info2[cpu_index].idle-stat_info1[cpu_index].idle;
				MS_U64 cpu = ( stat_info2[cpu_index].user+stat_info2[cpu_index].nice+ stat_info2[cpu_index].sys+stat_info2[cpu_index].idle  \
						+stat_info2[cpu_index].iowait +stat_info2[cpu_index].irq +stat_info2[cpu_index].softirq		) \
					- ( stat_info1[cpu_index].user+stat_info1[cpu_index].nice+ stat_info1[cpu_index].sys+stat_info1[cpu_index].idle \
						+stat_info1[cpu_index].iowait +stat_info1[cpu_index].irq +stat_info1[cpu_index].softirq		);

				float usage=0;
				if(0!=cpu){
					usage=100.0-(idle * 100.0) / cpu;	
				}else{
					usage=0;
				}
				if(usage>100){
					usage=100;
				}
				pcpu_info->usage[cpu_index]=usage;	
			}
		}else{
			ms_errRet(-1, "Get cpustat2 error");
		}
	}
	//ms_verbose("get temperature");
	static time_t timep_checkEx=0;
	if(mstime_api_counterAsyncSec(&timep_checkEx,ms_minutes(1))){
		mspmc_innerapi_getCpuTemperature( sysperform_info);
		mspmc_innerapi_getCpuMhz(sysperform_info);
		mspmc_innerapi_getCpuRunMode(sysperform_info);
	}
	//ms_verbose("checksysperforminfo");
	mspmc_innerapi_checkSystemInfo(waring_func, flag_disable_checkmem, flag_disable_checkdisk, flag_disable_checkcpu);
	//ms_verbose("end");
#endif
	return 0;
}
char mspmc_api_deinit(ms_void)
{
	if(1!=flag_mspmc_init){
		return -1;
	}
	fclose(fp_meminfo);
	fclose(msfp_netdev);
	fclose(fp_stat);
	fclose(fp_diskstats);
	fclose(fp_mounts);
	flag_mspmc_init=0;
}
ms_void mspmc_api_checkEthernet(ms_void)
{
	static MSPMCDNSList pmcDnsList[]={
		{"百度公共DNS",{"180.76.76.76",ms_null}},
		{"阿里公共DNS",{"223.5.5.5","223.6.6.6",ms_null}},
		{"字节跳动公共DNS",{"180.184.1.1","180.184.2.2",ms_null}},
		{"谷歌公共DNS",{"8.8.8.8","8.8.4.4",ms_null}},
		{"腾讯云DNS",{"119.29.29.29","182.254.116.116",ms_null}},
		{"华为云DNS",{"122.112.208.1","139.9.23.90",ms_null}},
		{"中科大DNS",{"202.141.162.123","202.38.93.153",ms_null}},
		{ms_null}
	};	

	/*使用上次可达的地址来加速检测效率*/
	static ms_string dbName=ms_null;	//用于记录上次可达的IP地址
	static ms_string dbIpaddr=ms_null;	//用于记录上次可达的IP地址
	if(ms_null!=dbIpaddr){
		sysperform_info.is_connected_ethernet=msnet_api_ping(dbIpaddr);
		ms_verbose("ping  %s(%s):%s",dbName,dbIpaddr,sysperform_info.is_connected_ethernet?"reachable" : "unreachable");
		if(ms_true==sysperform_info.is_connected_ethernet){
			return;
		}
	}
	static ms_s32 cplItem=0;
	static ms_s32 dnsItem=0;	
	ms_s32 num=0;
	/*每次3个地址，轮循检测*/
	while(ms_true){		
		if(ms_null==pmcDnsList[cplItem].name){
			cplItem=0;
		}
		while(ms_true){
			ms_string ipaddr=pmcDnsList[cplItem].ipaddr_list[dnsItem];
			if(ms_null==ipaddr){
				dnsItem=0;
				break;
			}
			sysperform_info.is_connected_ethernet=msnet_api_ping(ipaddr);
			dnsItem++;	
			ms_verbose("%03d.ping  %s(%s):%s",num,pmcDnsList[cplItem].name,ipaddr,sysperform_info.is_connected_ethernet?"reachable" : "unreachable");
			if(ms_true==sysperform_info.is_connected_ethernet){
				dbName=pmcDnsList[cplItem].name;
				dbIpaddr=ipaddr;
				return;
			}	
			//每次只ping三个地址
			if(ms_noLess(num++, 2)){return;}
		}
		
		cplItem++;
	}
}
ms_void mspmc_api_neteExternInfo_msg(ms_string ifacename,const char * func,ms_s32 line)
{
	NETCARDInfo *pnetcard_info=&hardware_info.netcard_info;
	NETInfo *pnet_info=&sysperform_info.net_info;
	int eth_index=0;
	for(eth_index=0;eth_index<pnetcard_info->num;eth_index++){
		if(ms_strncmp_saeq(pnetcard_info->cfg_info[eth_index].name, ifacename)){
			NETInfo net_info_tmp;
			ms_stru0(&net_info_tmp, NETInfo)
			int ret=msethtool_api_getInfo(
			pnetcard_info->cfg_info[eth_index].name, 
			&net_info_tmp.speed[eth_index],  
			&net_info_tmp.duplex[eth_index] , 
			&net_info_tmp.autoneg[eth_index] , 
			&net_info_tmp.is_linkup[eth_index]) ;
			if(ret<0){
				pnet_info->is_linkup[eth_index]	=0;
				pnet_info->speed[eth_index]		=-1;
			}else{
				ms_byte tbuf[1024]={0};
				if(pnet_info->speed[eth_index]!=net_info_tmp.speed[eth_index]
					||pnet_info->duplex[eth_index]!=net_info_tmp.duplex[eth_index]
					||pnet_info->autoneg[eth_index]!=net_info_tmp.autoneg[eth_index]
					||pnet_info->is_linkup[eth_index]!=net_info_tmp.is_linkup[eth_index]){
					ms_waring("[func,line:%s,%d]%s network card information changes. "
						"The original (speed,duplex,autoneg,is_linkup) information is %d,%d,%d,%d, "
						"and now is %d,%d,%d,%d", func,line, pnetcard_info->cfg_info[eth_index].name,
						pnet_info->speed[eth_index],pnet_info->duplex[eth_index],
						pnet_info->autoneg[eth_index],pnet_info->is_linkup[eth_index],
						net_info_tmp.speed[eth_index],net_info_tmp.duplex[eth_index],
						net_info_tmp.autoneg[eth_index],net_info_tmp.is_linkup[eth_index]);
					ms_msleep(500);
				}else{
				#if 0	
					ms_byte tbuf[1024]={0};
					ms_debug("[func,line:%s,%d]%s network card information record. "
						"(speed,duplex,autoneg,is_linkup) information is %d,%d,%d,%d", func,line,pnetcard_info->cfg_info[eth_index].name,
						pnet_info->speed[eth_index],pnet_info->duplex[eth_index],
						pnet_info->autoneg[eth_index],pnet_info->is_linkup[eth_index]);
				#endif
				}
				pnet_info->speed[eth_index]=net_info_tmp.speed[eth_index];
				pnet_info->duplex[eth_index]=net_info_tmp.duplex[eth_index];
				pnet_info->autoneg[eth_index]=net_info_tmp.autoneg[eth_index];
				pnet_info->is_linkup[eth_index]=net_info_tmp.is_linkup[eth_index];
			}
			break;
		}
	}
}
char mspmc_api_netInfo(NETCARDInfo *pnetcard_info)
{
#if defined(OS_LINUX_SOC)
	ms_bufcheckRet(-1, pnetcard_info);
	ms_u08 eth_index=0;
	//Get mac,mtu,ip,netmask
	for(eth_index=0;eth_index<pnetcard_info->num;eth_index++){
		NETCFGInfo * pnetcfg_info=(NETCFGInfo *)&pnetcard_info->cfg_info[eth_index];
		msnet_api_getIfaceMac_string(pnetcfg_info->name, pnetcfg_info->address, ms_bufsize(pnetcfg_info->address));
		msnet_api_getIfaceMtu(pnetcfg_info->name, pnetcfg_info->mtu, sizeof(pnetcfg_info->mtu));
		msnet_api_getIfaceInfo(pnetcfg_info);
	}
	//Get gateway
	if(ms_true==msmd_api_isInstallByBin("ip")){
		ms_byte info[1024]={0};
		ms_s32 len=ms_cmdRead("ip route show table  main",  info, ms_bufsize(info));
		if(len>0){
			//ms_verbose("info:\r\n%s",info);
			char line[1024]={0};
			ms_ps08 p =info;	
			while(0!=*p){
				msstr_api_getLine(line, ms_bufsize(line), (const char **)&p);
				if(ms_buflen(line)>0){
					//ms_verbose("line:%s",line);
					if(msstr_api_isCasestr(line, "default") !=ms_false){
						char   gateway[msnet_maxlen_gw];
						char   name[msnet_maxlen_ifname];
						sscanf(line, "default via %s dev %s  proto static", (char *)&gateway,(char *)&name);
						for(eth_index=0;eth_index<pnetcard_info->num;eth_index++){
							NETCFGInfo * pnetcfg_info=(NETCFGInfo *)&pnetcard_info->cfg_info[eth_index];
							if(ms_strncmp_saeq(pnetcfg_info->name, name)){
								ms_sprintfs(pnetcfg_info->gateway, "%s", gateway);
								break;
							}
						}
						//ms_verbose("====================defalut:%s-%s",name,gateway);
					}else {
						char   netmaskbit[64];
						char   name[msnet_maxlen_ifname];
						sscanf(line, "%s dev %s  proto kernel  scope link", (char *)&netmaskbit,(char *)&name);
						for(eth_index=0;eth_index<pnetcard_info->num;eth_index++){
							NETCFGInfo * pnetcfg_info=(NETCFGInfo *)&pnetcard_info->cfg_info[eth_index];
							if(ms_strncmp_saeq(pnetcfg_info->name, name)){
								ms_sprintfs(pnetcfg_info->netmaskbit, "%s", netmaskbit);
								break;
							}
						}
						//ms_verbose("====================:%s-%s",name,netmaskbit);
					}	
				}
			}	
			//set user gateway
			for(eth_index=0;eth_index<pnetcard_info->num;eth_index++){
				NETCFGInfo * pnetcfg_info=(NETCFGInfo *)&pnetcard_info->cfg_info[eth_index];
				//ms_debug("%d/%d.====================gateway:%s-%s",pnetcard_info->num,eth_index,pnetcfg_info->name,pnetcfg_info->gateway);
				if(0==ms_buflen(pnetcfg_info->gateway)){
					ms_u08 eth_index2=0;
					//ms_verbose("====================finding gateway:%s",pnetcfg_info->name);
					for(eth_index2=0;eth_index2<pnetcard_info->num;eth_index2++){
						NETCFGInfo * pnetcfg_info2=(NETCFGInfo *)&pnetcard_info->cfg_info[eth_index2];
						//ms_verbose("%d.====================find gateway:%s-%s",eth_index2,pnetcfg_info2->name,pnetcfg_info2->gateway);
						if(ms_strncmp_saeq(pnetcfg_info->netmaskbit, pnetcfg_info2->netmaskbit)
							&&ms_buflen(pnetcfg_info2->gateway)>0){
							ms_strcpy(pnetcfg_info->gateway, pnetcfg_info2->gateway);
							//ms_verbose("====================find gateway:%s-%s",pnetcfg_info2->name,pnetcfg_info2->gateway);
							break;
						}
					}
					if(0==ms_buflen(pnetcfg_info->usrgateway)
						&&ms_buflen(pnetcfg_info->ipaddress)>0
						&&ms_buflen(pnetcfg_info->netmask)>0){
						msnet_api_getGatewayByNetmask(pnetcfg_info->ipaddress, pnetcfg_info->netmask, pnetcfg_info->netmaskbit,pnetcfg_info->usrgateway);
						ms_debug("usrgateway:%s-%s-%s-%s-%s",pnetcfg_info->name,pnetcfg_info->ipaddress, pnetcfg_info->netmask, pnetcfg_info->netmaskbit,pnetcfg_info->usrgateway);
					}	
				}
			}
		}
	}
#else
	ms_funcNosupports;
#endif
	return 0;
}

ms_void mspmc_api_buildOSinfo(char * outstr)
{
	char tbuf[1024]={0};
	ms_strcats(tbuf, outstr,"[%s]\r\n","cpuhw_info");
	ms_strcats(tbuf, outstr,"modelname:%s\r\n",hardware_info.cpuhw_info.modelname) ;
#if defined OS_PLATFORM_ARMV7L ||defined OS_PLATFORM_ARM64
	ms_strcats(tbuf, outstr,"bogomips:%s\r\n",hardware_info.cpuhw_info.bogomips) ;
#else
	ms_strcats(tbuf, outstr,"cpucores:%d\r\n",hardware_info.cpuhw_info.cpucores) ;
	ms_strcats(tbuf, outstr,"siblings:%d\r\n",hardware_info.cpuhw_info.siblings) ;
	ms_strcats(tbuf, outstr,"clflushsize:%d\r\n",hardware_info.cpuhw_info.clflushsize) ;
	ms_strcats(tbuf, outstr,"cachesize:%d\r\n",hardware_info.cpuhw_info.cachesize) ;
#endif
	ms_strcats(tbuf, outstr,"graphics:%s\r\n", hardware_info.pcidevinfo.vgainfo) ;	

	unsigned char netcard_index=0;
	ms_strcats(tbuf, outstr,"[%s]\r\n", "netcard_info");
	for(netcard_index=0;netcard_index<hardware_info.netcard_info.num;netcard_index++){
		ms_strcats(tbuf, outstr,"name:%s\r\n",hardware_info.netcard_info.cfg_info[netcard_index].name) ;
		ms_strcats(tbuf, outstr,"address:%s\r\n",hardware_info.netcard_info.cfg_info[netcard_index].address) ;
		ms_strcats(tbuf, outstr,"ipaddress:%s\r\n",hardware_info.netcard_info.cfg_info[netcard_index].ipaddress) ;
		ms_strcats(tbuf, outstr,"netmask:%s\r\n",hardware_info.netcard_info.cfg_info[netcard_index].netmask) ;
	}
	ms_strcats(tbuf, outstr,"[%s]\r\n", "software_info");
	if(1==os_info.is_littleendian){
		ms_strcats(tbuf, outstr,"storage_pattern:%s\r\n", "littleendian");
	}else{
		ms_strcats(tbuf, outstr,"storage_pattern:%s\r\n", "bigendian");
	}
	ms_strcats(tbuf, outstr,"sysname:%s\r\n", os_info.sysname);
	ms_strcats(tbuf, outstr,"nodename:%s\r\n", os_info.nodename);
	ms_strcats(tbuf, outstr,"release:%s\r\n",os_info.release);
	ms_strcats(tbuf, outstr,"version:%s\r\n", os_info.version);
	ms_strcats(tbuf, outstr,"machine:%s\r\n", os_info.machine);
	ms_strcats(tbuf, outstr,"server_starttime:%s\r\n", os_info.server_starttime);
	ms_strcats(tbuf, outstr,"has_safenetdriver:%d\r\n", os_info.has_safenetdriver);


	ms_strcats(tbuf, outstr,"[%s]\r\n", "cpu_info");
	ms_strcats(tbuf, outstr,"(used/total):%f\r\n", sysperform_info.cpu_info.usage[0]);
	
	ms_strcats(tbuf, outstr,"[%s]\r\n", "mem_info");
	ms_strcats(tbuf, outstr,"(used/total):%d/%d\r\n", 
		(sysperform_info.mem_info.total-sysperform_info.mem_info.free),sysperform_info.mem_info.total);	

	ms_strcats(tbuf, outstr,"[%s]\r\n", "disk_info");
	DISKInfo*pdiskinfo=&sysperform_info.disk_info;
	unsigned char mountpoint_index=0;
	for(mountpoint_index=0;mountpoint_index<pdiskinfo->mountpoint_num;mountpoint_index++){
		MOUNTInfo *pmount_info=&pdiskinfo->mount_info[mountpoint_index];
		ms_strcats(tbuf, outstr,"mountpoint(used/total):%s\t\t%s/%s\r\n",
			pmount_info->mntpoint,
			ms_num2str(pmount_info->dused),
			ms_num2str(pmount_info->dtotal));	
	}
}

char mspmc_api_getDevHWInfo(char *pdevInfo)
{
	cJSON * json_root = cJSON_CreateObject();
	if(ms_null == json_root){
		ms_errRet(-1,"cJSON_CreateObject failed");
	}
	if(mspmc_api_init( )<0){
		ms_errRet(-1,"mspmc_api_init failed");
	}
	CPUInfo *pcpu_info	=&sysperform_info.cpu_info;
	MSJSON_BUILD_STRING(json_root, "cpu_modelname",hardware_info.cpuhw_info.modelname) ;
	char tempbuf[256]={0};
	NETInfo *pnet_info=&sysperform_info.net_info;
	cJSON_AddNumberToObject(json_root, "netcard_num",hardware_info.netcard_info.num) ;	
	unsigned char netcard_index=0;
	for(netcard_index=0;netcard_index<hardware_info.netcard_info.num;netcard_index++){
		ms_sprintfs(tempbuf, "netcard%d_name",netcard_index);
		MSJSON_BUILD_STRING(json_root, tempbuf,hardware_info.netcard_info.cfg_info[netcard_index].name) ;
		ms_sprintfs(tempbuf, "netcard%d_address",netcard_index);
		MSJSON_BUILD_STRING(json_root,tempbuf,hardware_info.netcard_info.cfg_info[netcard_index].address) ;
	}

	MSJSON_BUILD_STRING(json_root, "dmidecode_info",hardware_info.dmidecode_info) ;
	MSJSON_BUILD_STRING(json_root, "blk_info_serialsda",hardware_info.blk_info_serialsda) ;
	MSJSON_BUILD_STRING(json_root, "systemuuid",hardware_info.systemuuid) ;
	MSJSON_BUILD_STRING(json_root, "processorid",hardware_info.processorid) ;
	char * json_string = cJSON_Print(json_root);
	cJSON_Delete(json_root);
	if(ms_null==json_string){
		ms_errRet(-1,"cJSON_Print failed");
	}	
	int len=ms_buflen(json_string);
	ms_strcpy(pdevInfo,json_string) ;
	ms_free(json_string);
	return 0;
}


#undef MSPERFORMANCE_C
